{extend name='common/base'}
{block name="content"}
<div class="row">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>基本表单 <small>简单登录表单示例</small></h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                    <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
                        <i class="fa fa-wrench"></i>
                    </a>
                    <ul class="dropdown-menu dropdown-user">
                        <li><a href="form_basic.html#">选项1</a>
                        </li>
                        <li><a href="form_basic.html#">选项2</a>
                        </li>
                    </ul>
                    <a class="close-link">
                        <i class="fa fa-times"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content">
                <div class="row">
                    <div class="col-sm-6 b-r">
                        <h3 class="m-t-none m-b">上传</h3>
                        <form role="form" method="post" enctype="multipart/form-data">
                            <div class="form-group">
                                <input type="file" name="newpic"  class="myfile"/>
                            </div>
                            <div class="form-group">
                                <button class="btn btn-primary" type="submit">保存</button>
                            </div>
                        </form>
                    </div>

                </div>
            </div>
        </div>
    </div>

</div>

{/block}
{block name="script"}
<script type="text/javascript">
    $(".myfile").fileinput({
        language: 'zh',
        uploadUrl: "{:url('queue/upload')}",
        showCaption: true,//是否显示被选文件的简介
        showUpload: false,//是否显示上传按钮
        showRemove: false,//是否显示删除按钮
        showClose: false,//是否显示关闭按钮
        showUploadedThumbs:true,
        dropZoneEnabled:false,
        enctype: 'multipart/form-data',
        uploadAsync:true, //false 同步上传，后台用数组接收，true 异步上传，每次上传一个file,会调用多次接口
        previewFileIcon: "<i class=‘glyphicon glyphicon-king‘></i>",
//    layoutTemplates: {
////      actionUpload: '',//就是让文件上传中的文件去除上传按钮
////        actionDelete: ''//去除删除按钮
//    },
        browseClass: 'btn btn-primary',
        maxFileCount: 10,
        minFileCount : 1,
    }) .on('filebatchselected', function(event, files) {
        // 选中事件
        $(event.target).fileinput('upload')
    }).on('filebatchuploadsuccess',function(res) {
        console.log(res);
    });
    //异步上传返回结果处理
    $('.myfile').on('fileerror', function(event, data, msg) {
        console.log("fileerror");
        console.log(data);
    });
    //异步上传返回结果处理
    $(".myfile").on("fileuploaded", function(event, data, previewId, index) {
        console.log("fileuploaded");
        var ref = $(this).attr("data-ref");
        console.log(ref);
        $("input[name='" + ref + "']").val(data.response.data);

        $('#' + previewId).attr('myOperationData', data.response.data );
        $('#' + previewId).attr('title', data.response.data );

    });

    //上传前
    $('.myfile').on('filepreupload', function(event, data, previewId, index) {
        console.log("filepreupload");
    });

</script>
{/block}